import time

from selenium import webdriver


class UtilsDriver:
    _driver = None
    # 定义获取驱动对象的方法
    @classmethod  #表示该方法是一个类级别方法，可以使用类名加函数名调用
    def get_driver(cls):
        if cls._driver is None:
            cls._driver = webdriver.Chrome()
            cls._driver.maximize_window()
            cls._driver.implicitly_wait(5)
        return cls._driver

    @classmethod
    def quit_driver(cls):
        if cls._driver is not None:
            cls.get_driver().quit()
            cls._driver = None


def get_msg():
    #获取弹框提示信息
    # driver = UtilsDriver()
    time.sleep(5)
    # return driver.get_driver().find_element_by_xpath('//*[@id="ai-topsearch"]/span').text
    return UtilsDriver.get_driver().find_element_by_xpath('//*[@id="ai-topsearch"]/span').text



